package org.hugoduncan.appam.server.impl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.ServletException;

import org.hugoduncan.appam.server.AppServletRequest;
import org.hugoduncan.appam.server.AppServletResponse;
import org.hugoduncan.appam.server.PathHandler;
import org.hugoduncan.appam.server.PathHandlerManager;

public class PathHandlerManagerImpl 
    implements PathHandlerManager
{
    Collection<PathHandler> pathHandlers=new ArrayList<PathHandler>();
    
    public void addPathHandler(PathHandler handler) {
        pathHandlers.add(handler);
    }

    public boolean process(AppServletRequest request, AppServletResponse response) 
        throws IOException, ServletException 
    {
        for (PathHandler handler:pathHandlers)
            if (handler.process(request, response))
                return true;
        return false;
    }

}
